const Router = require("koa-router");
const jwt = require("koa-jwt");
const router = new Router({ prefix: "/question" });
const {
  find,
  findByTitle,
  findByType,
  create,
  update,
  del,
  slicePages
} = require("../controllers/examinations");
const { isAllowed } = require("../middleware/authorize");
const secret = process.env.SECRET;
const auth = jwt({ secret });

console.log(typeof isAllowed);
router.get("/", find);
router.get("/slice", slicePages);
router.get("/title", findByTitle);
router.get("/type/:type", auth, findByType);
router.post("/create", auth, create);
router.patch("/update/:id", auth, update);
router.delete("/:id", auth, del);
module.exports = router;
